package giab.weixin.web.view.error;

import giab.weixin.web.util.RequestExecuteData;
import giab.weixin.web.util.XmlUtil;
import giab.weixin.web.xml.bean.WxMessagePut;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;



@Controller

public class DefaultError {
	
	@Autowired
	private RequestExecuteData red;
	@Autowired
	private XmlUtil xmlUtil;
	
	private Logger logger = LoggerFactory.getLogger(DefaultError.class);
	
	@RequestMapping("/defaultError")
	public ModelAndView show500Error(HttpServletRequest request,HttpServletResponse response){		
		String message = red.getPostData(request);		
		if(message!=null){
			Object ob = xmlUtil.xmlToObject(message, WxMessagePut.class);
			if (ob!=null) {
				WxMessagePut wx = (WxMessagePut)ob;
				System.out.println(wx.getCreateTime());
			}
		}
		logger.debug(message);
		ModelAndView modelAndView = new ModelAndView("error");
		return modelAndView;
	}

}
